<?php
declare (strict_types = 1);
namespace app\index\model\common;

use think\Model;

/**
 * @mixin \think\Model
 */
class Menu extends Model
{
    protected $pk = "id";

    /**
     * 获取菜单栏
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    function getUserCenterMenu($addWhere = []){
        $where = ['is_show'=>1];
        $field = 'id,title,menu_icon,menu_url,menu_sort';
        $urlName = config('index.web_url');
        return $this->where($where)->field($field)->order('menu_sort','desc')
            ->select()->each(function ($item)use($urlName){
                $item['menu_icon'] = $urlName.$item['menu_icon'];
            })->toArray();
    }





}
